/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Admin_Login.java
 *
 * Created on Mar 29, 2011, 9:08:08 PM
 */

package admin_gui;

import admin.Controller.LoginController;
import javax.swing.JOptionPane;

/**
 *
 * @author edaype
 */
public class Admin_Login extends javax.swing.JPanel {

    /** Creates new form Admin_Login */
    private String name;
    private String pwd;
   // private AdminGUI adminGUI;
    private LoginController aController;
    /** Creates new form Login
     * @param aThis 
     */
    public Admin_Login(AdminGUI aThis) {
  //      adminGUI = aThis;
        initComponents();
        aController = new LoginController(aThis);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        TitleLabel = new javax.swing.JLabel();
        LogoLabel = new javax.swing.JLabel();
        PasswordLabel = new javax.swing.JLabel();
        UserField = new javax.swing.JTextField();
        LoginButton = new javax.swing.JButton();
        UserLabel = new javax.swing.JLabel();
        PasswordField = new javax.swing.JPasswordField();
        ISLabel = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));

        TitleLabel.setFont(new java.awt.Font("Tahoma", 0, 48));
        TitleLabel.setText("Administration Login");

        LogoLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/admin_gui/images/Logo.png"))); // NOI18N

        PasswordLabel.setFont(new java.awt.Font("Tahoma", 0, 36));
        PasswordLabel.setText("Password");

        UserField.setFont(new java.awt.Font("Tahoma", 0, 24));

        LoginButton.setFont(new java.awt.Font("Tahoma", 0, 18));
        LoginButton.setText("Login");
        LoginButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LoginButtonActionPerformed(evt);
            }
        });

        UserLabel.setFont(new java.awt.Font("Tahoma", 0, 36));
        UserLabel.setText("User Name");

        PasswordField.setFont(new java.awt.Font("Tahoma", 0, 28));

        ISLabel.setFont(new java.awt.Font("Lucida Console", 0, 11));
        ISLabel.setText("Powered by Interactive Solutions");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ISLabel)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(356, 356, 356)
                .addComponent(LogoLabel)
                .addContainerGap(367, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(294, 294, 294)
                .addComponent(TitleLabel)
                .addContainerGap(296, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(53, 53, 53)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(UserLabel, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(PasswordLabel, javax.swing.GroupLayout.Alignment.TRAILING))
                .addGap(24, 24, 24)
                .addComponent(PasswordField, javax.swing.GroupLayout.DEFAULT_SIZE, 543, Short.MAX_VALUE)
                .addGap(229, 229, 229))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(841, Short.MAX_VALUE)
                .addComponent(LoginButton, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(42, 42, 42))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(252, Short.MAX_VALUE)
                .addComponent(UserField, javax.swing.GroupLayout.DEFAULT_SIZE, 543, Short.MAX_VALUE)
                .addGap(229, 229, 229))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(55, 55, 55)
                .addComponent(TitleLabel)
                .addGap(62, 62, 62)
                .addComponent(LogoLabel)
                .addGap(49, 49, 49)
                .addComponent(UserLabel)
                .addGap(10, 10, 10)
                .addComponent(UserField, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(88, 88, 88)
                        .addComponent(PasswordLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 184, Short.MAX_VALUE)
                        .addComponent(ISLabel))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(127, 127, 127)
                        .addComponent(PasswordField, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(30, 30, 30)
                        .addComponent(LoginButton, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void LoginButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LoginButtonActionPerformed
        name = UserField.getText();
        pwd = new String(PasswordField.getPassword());
        if (name.equals("") || pwd.equals("")) {
            JOptionPane.showMessageDialog(null, "Sorry! Please enter an userid and password .",
                    "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            aController.loginControl(name, pwd);
        }
    }//GEN-LAST:event_LoginButtonActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel ISLabel;
    private javax.swing.JButton LoginButton;
    private javax.swing.JLabel LogoLabel;
    private javax.swing.JPasswordField PasswordField;
    private javax.swing.JLabel PasswordLabel;
    private javax.swing.JLabel TitleLabel;
    private javax.swing.JTextField UserField;
    private javax.swing.JLabel UserLabel;
    // End of variables declaration//GEN-END:variables

}
